(function (obj) {
    function messageCount1(obj) {


        let objID = obj.id
        bottomInit(objID)
        document.getElementById(objID).style.backgroundColor = "rgba(102,102,153,.8)"
        document.getElementById(objID).style.color = "rgb(255,255,255)"
        document.getElementById(objID).style.boxShadow = "0 0 0 white"
        document.getElementById(objID).style.border = "2px solid rgba(204,204,204,1)"
        let span = document.getElementById(objID).getElementsByTagName("span")
        for (const spanElement of span) {
            if (spanElement.getAttribute("name") === "badge") {
                spanElement.setAttribute("hidden", "true")
            }
        }
        $("#messageCenterText0001").text("用户管理消息")

        $.post("/messageCenter/findSysAuthAuditMessage", {}, function (result) {
            let index = 0
            if (result.data.length > 0) {
                for (const resultElement of result.data) {
                    index++
                    let cardDiv = document.createElement("div")
                    cardDiv.setAttribute("id", "cardDiv" + index)
                    cardDiv.className = "cardDiv shadow-sm bg-white rounded"

                    let userAuditMessageImage = document.createElement("div")
                    userAuditMessageImage.className = "userAuditMessageImage"
                    userAuditMessageImage.innerText = "UA"

                    let messageName = document.createElement("span")
                    messageName.className = "userAuditMessageName text-muted"
                    messageName.innerText = "用户认证"

                    let lastUser = document.createElement("span")
                    lastUser.className = "userAuditLastUser"
                    lastUser.innerText = "申请账户:" + resultElement.existUserEntity.uname


                    let fullName = document.createElement("span")
                    fullName.className = "userAuditFullName userAuditLastUser"
                    fullName.innerText = "真实姓名:" + resultElement.toUserEntity.fullname

                    let group1 = resultElement.toUserEntity.groupId
                    let groupAlias = groupType(group1)


                    let group = document.createElement("span")
                    group.className = "userAuditGroup userAuditLastUser"
                    group.innerText = "认证归属:" + groupAlias


                    let actionDiv = document.createElement("div")
                    actionDiv.className = "actionDiv"


                    let auditPassBtn = document.createElement("button")
                    auditPassBtn.className = "btn btn-success auditPassBtn"
                    auditPassBtn.innerText = "通过"
                    auditPassBtn.setAttribute("id", "auditPassBtn")
                    auditPassBtn.addEventListener("click", function () {
                        auditPassBtnFun(resultElement.existUserEntity.uname, index)
                    })

                    let auditNGBtn = document.createElement("button")
                    auditNGBtn.className = "btn btn-warning auditNGBtn"
                    auditNGBtn.innerText = "驳回"
                    auditNGBtn.setAttribute("id", "auditNGBtn")
                    auditNGBtn.addEventListener("click", function () {
                        auditNGBtnFun(resultElement.existUserEntity.uname, index)
                    })

                    cardDiv.appendChild(userAuditMessageImage)
                    cardDiv.appendChild(messageName)
                    cardDiv.appendChild(lastUser)
                    cardDiv.appendChild(fullName)
                    cardDiv.appendChild(group)
                    actionDiv.appendChild(auditPassBtn)
                    actionDiv.appendChild(auditNGBtn)
                    cardDiv.appendChild(actionDiv)

                    document.getElementById("messageSidBar_ul0001").appendChild(cardDiv)
                }

            }
        })
    }

    function auditPassBtnFun(str, index) {

        $.post("/messageCenter/auditPassBtnFun", {userName: str}, function (result) {
            if (result.flag) {

                $("#messageCenterText0001").text("用户" + str + "认证请求已通过！")
                document.getElementById("cardDiv" + index).remove()
                messageCount()
            }

        })
    }

    function auditNGBtnFun(str, index) {
        $.post("/messageCenter/auditNGBtnFun", {userName: str}, function (result) {
            if (result.flag) {

                $("#messageCenterText0001").text("用户" + str + "认证请求已驳回！")
                document.getElementById("cardDiv" + index).remove()
                messageCount()
            }
        })
    }

    window.messageCount1 = messageCount1
    window.auditPassBtnFun = auditPassBtnFun
    window.auditNGBtnFun = auditNGBtnFun
}(window));